package com.lin.security.util;


import com.lin.security.SecurityUser;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author linze
 * @version 1.0
 * @Description
 * @Date 2021/1/21 18:03
 */
public class SecurityUtil {
    public static int getCurrentUserUid() {
        return (int) SecurityContextHolder
                .getContext().getAuthentication().getPrincipal();
    }

    public static String getCurUserIdentity() {
        SecurityUser securityUser = (SecurityUser) SecurityContextHolder
                .getContext().getAuthentication().getCredentials();
        return securityUser.getRole();
    }
}
